import type { AxiosRequestConfig } from "axios";
import axios from "axios";
import { getToken } from "./localToken";

// export const uploadFile = (url: string, formData?: any) => {

//   const configUpload: AxiosRequestConfig = {
//     baseURL: '/admin-service',
//     timeout: 30000 as number,
//   }
//   const token = getToken()
//   const new_header= { 'Authorization': token, 'Content-Type': 'multipart/form-data' }
//   configUpload['headers'] = new_header

//   const newService = axios.create()
//   return newService.post(url, formData, configUpload)
// }

export const uploadFile = (formData: any) => {
  const configUpload: AxiosRequestConfig = {
    baseURL: 'http://120.53.238.14:8801/admin-service',
    // baseURL: "http://10.3.73.70:8801/admin-service",
    timeout: 30000 as number,
  };
  const token = getToken();
  const new_header = {
    Authorization: token,
    "Content-Type": "multipart/form-data",
  };
  configUpload["headers"] = new_header;

  const newService = axios.create();
  return newService.post("/storage/file/upload", formData, configUpload);
};
